<template>
  <div class="main">
    <el-container class="main-content">
      <el-aside :width="isCollapse ? '60px' : '210px'">
        <mainMenu :is-fold="isCollapse"></mainMenu>
      </el-aside>
      <el-container>
        <el-header height="50px">
          <mainHeader @fold-change="handelFoldChange"></mainHeader>
        </el-header>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script setup lang="ts">
import { localCache } from '@/utils/storage'
import { LOGIN_TOKEN } from '@/global/constants'
import router from '@/router/index'
import mainMenu from '@/components/main-menu/main-menu.vue'
import mainHeader from '@/components/main-header/main-header.vue'
import { ref } from 'vue'

const logoutFn = () => {
  localCache.removeStorage(LOGIN_TOKEN)

  router.push('/login')
}

const isCollapse = ref(false)

const handelFoldChange = (isFold: boolean) => {
  console.log(isFold)

  isCollapse.value = isFold
}
</script>

<style scoped lang="less">
.main {
  height: 100%;

  .main-container {
    height: 100%;
  }

  .el-header {
    background-color: #fff;
  }

  .el-container {
    background-color: #f2f2f2;
  }

  &-content {
    height: 100%;

    .el-aside {
      overflow-x: hidden;
      overflow-y: auto;
      line-height: 200px;
      text-align: left;
      cursor: pointer;
      scrollbar-width: none;
      -ms-overflow-style: none;
      transition: width 0.5s ease;

      &::-webkit-scrollbar {
        display: none;
      }
    }
  }
}
</style>
